package com.example.consumer;

import com.example.entity.VideoMessage;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class Tiktok {

    private final List<VideoMessage> messages = new ArrayList<>();

    // 监听 "logistics.topic" 主题
    @JmsListener(destination = "video.topic", containerFactory = "topicListenerFactory")
    public void receive(VideoMessage message) {
        System.out.println("抖音爱好者收到信息：" + message);  // 打印消息
        if(message.getPlatformName().equals("抖音"))messages.add(message);  // 将接收到的消息添加到列表
    }

    // 获取商家接收到的所有消息
    public List<VideoMessage> getMessages() {
        return messages;
    }
}
